<template>
	<view class="exit" >
		<view class="header">
			<image @tap = "backTomine" src="../../../assets/images/arr-l.png" mode=""></image>
			<text>个人中心</text>
		</view>
		<view class="image">
			<text>头像</text>
			<image :src="exitInfo.avatar" mode=""></image>
		</view>
		<view class="image">
			<text>用户名</text>
			<text>{{ exitInfo.username }}</text>
		</view>
		<view class="image">
			<text>昵称</text>
			<text>{{ exitInfo.nickname }}</text>
		</view>
		<view class="image">
			<text>手机号</text>
			<text>{{ exitInfo.tel }}</text>
		</view>
		
		<view class="button" @tap = "doLogout(Id)">
			退出登录
		</view>
	</view>
</template>

<script>
	import http from "../../../utils/http.js"
	export default {
		data() {
			return {
				exitInfo:'',
				// Id:"1",
				Id:'',
			};
		},
		onShow(){
			
			
			
		},
		onLoad(){
			this.exitInfo = uni.getStorageSync("token");
			console.log(uni.getStorageSync("token"));
			
			console.log(this.exitInfo);
			this.Id=this.exitInfo.sessionId;
			// console.log(this.id);
		},
		methods:{
			backTomine(){
				uni.switchTab({
					url:"/pages/mine/mine"
				})
			},
			doLogout(val){
				http.get("/api/leju/front/user/doLogout").then(res =>{
					console.log(res);
					if(res.data.code == "S"){
						uni.showModal({
							title: '退出登录',
							content: '确认退出',
							success: function (res) {
								if (res.confirm) {
									uni.clearStorageSync("token");
									uni.switchTab({
										url:`/pages/mine/mine?id=${val}`
									});	
										//强制刷新,跳转到我的页面时不会刷新，需要强制刷新。
										uni.navigateBack()
									
								} else if (res.cancel) {
									console.log('取消');
								}
							}
						});	
						
						
						
						
					}
				})
			}
		}
		
	}
</script>

<style lang="scss">
	.exit{
		width:750rpx;
		height: 100vh;
		background:wheat;
		.header{
			width:100%;
			height: 80rpx;
			background: #5D4E49;
			padding:0.1rpx;
			image{
				position:absolute;
				left:33rpx;
				top:28rpx;
				width:24px;
				height: 38rpx;
			}
			text{
				display:block;
				width:120rpx;
				height: 50rpx;
				line-height: 50rpx;
				text-align:center;
				font-weight:bolder;
				color:white;
				margin:0 auto;
				margin-top:20rpx;
				font-size:30rpx;
			}
		}
		.image{
			width:600rpx;
			margin: 0 auto;
			display:flex;
			justify-content: space-between;
			align-items: center;
			image{
				width:30rpx;
				height: 30rpx;
			}
		}
		.button{
			width:400rpx;
			height: 80rpx;
			font-size:60rpx;
			line-height: 80rpx;
			text-align:center;
			background-color: black;
			color:white;
			margin:0 auto;
			margin-top:50rpx;
			
		}
	}
</style>
